/*
 * Copyright (c) [2012] - [2017] Red Hat, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
package com.codenvy.api;

import com.codenvy.api.user.server.AdminUserCreator;
import com.codenvy.api.user.server.AdminUserService;
import com.codenvy.api.user.server.AdminUserServicePermissionsFilter;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
import org.eclipse.che.multiuser.api.permission.server.SystemDomain;
import org.eclipse.che.multiuser.permission.user.UserProfileServicePermissionsFilter;
import org.eclipse.che.multiuser.permission.user.UserServicePermissionsFilter;

/**
 * Initialize all components necessary for Admin User API.
 *
 * @author Anatoliy Bazko
 */
public class AdminApiModule extends AbstractModule {

  @Override
  protected void configure() {
    bind(AdminUserService.class);

    final Multibinder<String> binder =
        Multibinder.newSetBinder(
            binder(), String.class, Names.named(SystemDomain.SYSTEM_DOMAIN_ACTIONS));
    binder.addBinding().toInstance(UserServicePermissionsFilter.MANAGE_USERS_ACTION);

    bind(AdminUserServicePermissionsFilter.class);
    bind(UserProfileServicePermissionsFilter.class);
    bind(UserServicePermissionsFilter.class);
    bind(AdminUserCreator.class);
  }
}
